import { FlowGraph } from "../../../graph/index";

export function nodeOpt(id: any, globalGridAttr: any) {
  let curCel: any = null;
  if (id.value) {
    const { graph } = FlowGraph;
    const cell = graph.getCellById(id.value);
    if (!cell || !cell.isNode()) {
      return;
    }
    curCel = cell;
    globalGridAttr.nodeStroke = cell.attr("body/stroke");
    globalGridAttr.nodeStrokeWidth = cell.attr("body/strokeWidth");
    globalGridAttr.nodeFill = cell.attr("body/fill");
    globalGridAttr.nodeText = cell.attr("text/text") || ""; // 添加节点文本初始化
    globalGridAttr.nodeFontSize = cell.attr("text/fontSize");
    globalGridAttr.nodeColor = cell.attr("text/fill");
    globalGridAttr.nodeUsers = cell.attr("approve/users");
  }
  return curCel;
}
